package com.yanqu.road.entity.log.cross;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.log.ServerBaseLog;

@FieldTypeAnnotation(tableName = "t_l_ck_douluodalu_hunhuan", desc = "斗罗/封神世界魂环获取/失去日志", autoSave = true, uploadCk = true, isCross = true)
public class LogDouLuoDaLuHunHuan extends ServerBaseLog {

    @FieldTypeAnnotation(desc = "活动id", isIndex = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "玩家id", isIndex = true)
    private long userId;

    @FieldTypeAnnotation(desc = "1获得;0失去")
    private int type;

    @FieldTypeAnnotation(desc = "所在区域id")
    private int regionId;

    @FieldTypeAnnotation(desc = "魂环id")
    private String hunHuan;

    @FieldTypeAnnotation(desc = "1:击杀魂兽;2:击杀真人;3:被击杀;4：击杀真人，系统掉落  5：被击杀，系统掉落")
    private int reason;

    @FieldTypeAnnotation(desc = "对手")
    private long enemyUserId;

    public LogDouLuoDaLuHunHuan(int activityId, long userId, int type, int regionId, String hunHuan, int reason, long enemyUserId) {
        this.activityId = activityId;
        this.userId = userId;
        this.type = type;
        this.regionId = regionId;
        this.hunHuan = hunHuan;
        this.reason = reason;
        this.enemyUserId = enemyUserId;
    }

    public static int getReason(int reason, boolean lose) {
        if (reason == 1) {
            return reason;
        }
        if (reason == 2) {
            return lose ? reason : 4;
        }
        if (reason == 3) {
            return lose ? reason : 5;
        }
        return reason;
    }

    public long getUserId() {
        return userId;
    }

}
